package com.slz3.business.module.configManagement.conVersion.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.slz3.business.frame.enums.AuditFlag;
import com.slz3.business.frame.enums.UsingFlag;
import com.slz3.business.frame.enums.YNFlag;
import com.slz3.business.frame.functions.Add;
import com.slz3.business.frame.functions.Modify;
import com.slz3.business.frame.module.DomainEntity;
import com.slz3.business.module.configManagement.conVersion.enums.ConVersionAndroidChannelType;
import com.slz3.business.module.configManagement.conVersion.enums.ConVersionAppStoreUpEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.Type;
import org.hibernate.validator.constraints.Length;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import java.time.LocalDate;

import static javax.persistence.EnumType.STRING;

@MappedSuperclass
@Data
@EqualsAndHashCode(callSuper = false)
public class ConVersionEntity extends DomainEntity {

    //    /**
//     * 编号
//     */
//    @Column(length = 80)
//    @NotNull(message = "serNum 必须非空!", groups = {Add.class, Modify.class})
//    @Length(min = 1, max = 80, message = "ser2 必须非空并且不超过 80 个字符!", groups = {Add.class, Modify.class})
    private String serNum;

    /**
     * 备注
     */
    @Basic(fetch = FetchType.LAZY)
    @Type(type = "text")
    private String serMemo;

    /**
     * 审核状态
     */
    @Enumerated(STRING)
    @NotNull(message = "serAudit 必须非空!", groups = {Add.class})
    @Null(message = "serAudit 必须为空!", groups = {Modify.class})
    private AuditFlag serAudit;

    //    /**
//     * 启用状态
//     */
//    @Enumerated(STRING)
//    @NotNull(message = "serUsing 必须非空!", groups = {Add.class})
//    @Null(message = "serUsing 必须为空!", groups = {Modify.class})
    private UsingFlag serUsing;

    /**
     * 标签
     */
    private String serLabels;

    /**
     * 文件 url 地址
     */
    private String serFileUrl;

    /**
     * 富文本编辑器内容
     */
    @Basic(fetch = FetchType.LAZY)
    @Column(columnDefinition = "TEXT")
    private String serEditorContent;

    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
    private LocalDate serInputGroupData;

    /**
     * 内部对比版本号
     */
    @NotNull(message = "内部对比版本号 必须非空!", groups = {Add.class, Modify.class})
    private Integer serBuildNo;

    /**
     * APP版本号
     */
    @NotNull(message = "APP版本号 必须非空!", groups = {Add.class, Modify.class})
    @Length(min = 1, max = 200, message = "必须非空并且不超过 200 个字符!", groups = {Add.class, Modify.class})
    private String serVersionNumber;

    /**
     * 版本名称
     */
    @NotNull(message = "版本名称 必须非空!", groups = {Add.class, Modify.class})
    @Length(min = 1, max = 200, message = "必须非空并且不超过 200 个字符!", groups = {Add.class, Modify.class})
    private String serVersionName;

    /**
     * 简要说明
     */
    @NotNull(message = "简要说明 必须非空!", groups = {Add.class, Modify.class})
    @Length(min = 1, max = 200, message = "必须非空并且不超过 200 个字符!", groups = {Add.class, Modify.class})
    private String serVersionContent;

    /**
     * 操作系统
     */
    @NotNull(message = "操作系统 必须非空!", groups = {Add.class, Modify.class})
    @Enumerated(STRING)
    private OperatingSystemEnum serOperatingSystem;

    /**
     * 强制类型
     */
    @NotNull(message = "强制类型 必须非空!", groups = {Add.class, Modify.class})
    @Enumerated(STRING)
    private YNFlag serVersionUpgrade;

    /**
     * 下载地址
     */
    @NotNull(message = "下载地址 必须非空!", groups = {Add.class, Modify.class})
    @Column(columnDefinition = "TEXT")
    private String serDownloadAddress;

    /**
     * android 渠道类型
     */
    @Enumerated(STRING)
    private ConVersionAndroidChannelType serAndroidChannelType;

    /**
     * App 上架状态
     */
    @NotNull(message = "App 上架状态 必须非空!", groups = {Add.class, Modify.class})
    @Enumerated(STRING)
    private ConVersionAppStoreUpEnum enumAppStoreUp;

}
